from django.conf.urls import url
from . import views
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter

# urlpatterns = [
urlpatterns = [
    url(r"^usernames/(?P<username>\w{5,20})/count/$", views.Usernamecount.as_view()),
    url(r"^mobiles/(?P<mobile>1[3-9]\d{9})/count/$", views.Mobilecount.as_view()),
    url(r"^users/$", views.UersView.as_view()),
    url(r"^user/$", views.UserDataView.as_view()),
    url(r'^email/$', views.EmaileView.as_view()),
    url(r'^emails/verification/$', views.VerifyEmailView.as_view()),

    # jwt提供了登陆视图函数并有一个返回值token
    # 可以改写jwt的方法添加返回值字段
    # url(r"^authorizations/$", obtain_jwt_token),
    url(r"^authorizations/$",views.UserAuthorizeView.as_view()),

]

router = DefaultRouter()
router.register(r'addresses', views.AddressViewSet, base_name='addresses')

urlpatterns += router.urls

print(router.urls)

# Request URL:http://api.meiduo.site:8000/addresses/
# POST /addresses/ 新建  -> create
# PUT /addresses/<pk>/ 修改  -> update
# GET /addresses/  查询  -> list
# DELETE /addresses/<pk>/  删除 -> destroy
# PUT /addresses/<pk>/status/ 设置默认 -> status
# PUT /addresses/<pk>/title/  设置标题 -> title
